package com.lancoo.taskerdemo.item;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.lancoo.tasker.adapter.BaseRecyclerItem;
import com.lancoo.taskerdemo.R;
import com.lancoo.taskerdemo.mode.News;

/**
 * Created by gongwq on 2017/6/20 0020.
 */

public class NewsItem implements BaseRecyclerItem<News> {
    private TextView tv_title, tv_time, tv_author;
    private ImageView img;
    private Context mContext;

    public NewsItem(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public int getLayoutResId() {
        return R.layout.item_adapter;
    }

    @Override
    public void bindViews(View view) {
        tv_time = (TextView) view.findViewById(R.id.time_tv);
        tv_title = (TextView) view.findViewById(R.id.news_title);
        tv_author = (TextView) view.findViewById(R.id.author_tv);
        img = (ImageView) view.findViewById(R.id.news_img);
    }

    @Override
    public void setViews() {

    }

    @Override
    public void handleData(News data, int position) {
        tv_title.setText(data.getTitle());
        tv_time.setText(data.getDate());
        tv_author.setText(data.getAuthor_name());
        Glide.with(mContext).load(data.getThumbnail_pic_s()).into(img);
    }
}
